home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 60 / 60.xpi / chrome / webdeveloper.jar / content / webdeveloper / about / about.js < prev    next >
Text File  |  2009-06-30  |  1KB  |  43 lines

  1. // Opens the URL in a new tab
  2. function webdeveloper_openURL(urlElement)
  3. {
  4.     var parentWindow = null;
  5.     var url          = urlElement.firstChild.nodeValue;
  6.  
  7.     // If there is a parent window
  8.     if(window.opener)
  9.     {
  10.         // If there is a grand parent window
  11.         if(window.opener.opener)
  12.         {
  13.             parentWindow = window.opener.opener;
  14.         }
  15.         else
  16.         {
  17.             parentWindow = window.opener;
  18.         }
  19.     }
  20.  
  21.     // If a parent window was found
  22.     if(parentWindow)
  23.     {
  24.         // If the open in windows preference is set to true
  25.         if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs", true))
  26.         {
  27.             var newTab = parentWindow.getBrowser().addTab(url);
  28.  
  29.             // If the open tabs in background preference is not set or is set to false
  30.             if(!webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
  31.             {
  32.                 parentWindow.getBrowser().selectedTab = newTab;
  33.             }
  34.         }
  35.         else
  36.         {
  37.             parentWindow.open(url);
  38.         }
  39.  
  40.         window.close();
  41.     }
  42. }
  43.